#ifndef _BLE_H_
#define _BLE_H_
#include "global.h"
#include "log.h"
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "ble_const.h" 
#include "bluenrg_lp_stack.h"
#include "OTA_btl.h" 
#include "gatt_db.h"
#include "rf_driver_hal_vtimer.h"
#include "gap_profile.h"
#include "clock.h"
#include "bluenrg_lp_evb_config.h"

#define BLE_MTU                                     23
#define BLE_GATT_ATT_OP_LEN                         1
#define BLE_GATT_ATT_HANDLE_LEN                     2

typedef enum
{
    COMMUNICATION_INDEX = 0,
    MANAGEMENT_INDEX 
}ble_gatt_index;


typedef enum
{
    BLE_PARAM_RESP_DATA_SERIAL_NAME = 0,
    BLE_PARAM_RESP_DATA_HYPO,
    BLE_PARAM_RESP_DATA_HYPER,
    BLE_PARAM_CALLBACK_ON_WRITE,
    BLE_PARAM_CALLBACK_ON_CONNECT,
    BLE_PARAM_CONNECT_STATE,
    BLE_PARAM_CONNECT_INTERVAL,

}ble_param;

typedef enum
{
		sl_bt_evt_system_boot_id ,
		sl_bt_evt_connection_opened_id ,
		sl_bt_evt_connection_parameters_id ,
		sl_bt_evt_gatt_mtu_exchanged_id,
		sl_bt_evt_connection_closed_id ,
		sl_bt_evt_gatt_server_characteristic_status_id ,
		sl_bt_evt_gatt_server_attribute_value_id ,
		sl_bt_evt_gatt_server_user_write_request_id ,


}ble_event ;


typedef void (*fp_on_write)(uint16 u16_ConnetHandle, uint8_t Resp_Needed ,uint16 u16_AttIndex, const uint8 *u8p_Data, uint16 u16_Len);
typedef void (*fp_on_connect)(void);

void Ble_AppProcess(void) ;
uint Ble_InitAdv(void) ;
void Ble_UpdateAdvData
(
    uint8 * u8p_Data,
    uint16 u16_Length
) ;
void Ble_AttributeNotify
(
    uint16 u16_AttHandle,  
    uint8 *u8p_Data, 
    uint16 u16_Len
);
uint Ble_SetConfig
(
    uint ui_Parameter,
	uint8 *u8p_Value,
	uint ui_Length
);
uint Ble_GetConfig
(
    uint ui_Parameter,
	uint8 *u8p_Value,
	uint ui_Length
);












#endif